﻿using System;
using System.Text;

namespace dotHTML.HTML {
    /// <summary>
    /// Represents an option within a &lt;select&gt; element.
    /// </summary>
    [Serializable]
    public class Option : Element {
        private bool _disabled;
        private string _label;
        private bool _selected;
        private string _value;

        /// <summary>
        /// Determines whether or not this option is disabled.
        /// </summary>
        public bool Disabled {
            get { return _disabled; }
            set { _disabled = value; }
        }

        /// <summary>
        /// Determines the label of this option.
        /// </summary>
        public string Label {
            get { return _label; }
            set { _label = value; }
        }

        /// <summary>
        /// Determines whether or not this option is selected.
        /// </summary>
        public bool Selected {
            get { return _selected; }
            set { _selected = value; }
        }

        /// <summary>
        /// Determines the value of this option.
        /// </summary>
        public string Value {
            get { return _value; }
            set { _value = value; }
        }

        /// <summary>
        /// Gets a formatted string of all child elements of this element.
        /// </summary>
        /// <param name="sb">The StringBuilder to write this element's child
        /// data to.</param>
        protected override void WriteLocalAttributes(StringBuilder sb) {
            AttributeWriter.Write(sb, _disabled, "disabled");
            AttributeWriter.Write(sb, _label, "label");
            AttributeWriter.Write(sb, _selected, "selected");
            AttributeWriter.Write(sb, _value, "value");
        }
    }
}
